<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>注册页面 - 8282管理系统</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="8282管理系统,egg.js,Bootstrap,JQ,node.js,后台模板,后台管理系统">
<meta name="description" content="8282管理系统是基于Egg.js+LightYear构建的后台管理系统。">
<meta name="author" content="cadcamzy">
<link href="/public/css/bootstrap.min.css" rel="stylesheet">
<link href="/public/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/public/css/style.min.css" rel="stylesheet">
<link href="/public/css/animate.css" rel="stylesheet">
<style>
body {
    background-color: #fff;
}
.lyear-login-box {
    position: relative;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    -webkit-transition: 0.5s;
    -o-transition: 0.5s;
    transition: 0.5s;
}
.lyear-login-left {
    width: 50%;
    top: 0;
    left: 0;
    bottom: 0;
    position: fixed;
    height: 100%;
    z-index: 555;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
}
.lyear-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
}
.lyear-logo {
    margin-bottom: 50px;
}
.lyear-featured {
    z-index: 12;
    position: absolute;
    bottom: 0;
    padding: 30px;
    width: 100%;
}
.lyear-featured h4 {
    color: #fff;
    line-height: 32px;
}
.lyear-featured h4 small {
    color: #fff;
    display: block;
    text-align: right;
    margin-top: 15px;
}
.lyear-login-right {
    margin-left: 50%;
    position: relative;
    z-index: 999;
    padding: 100px;
    background-color: #fff;
}
@media screen and (max-width: 1024px) {
.lyear-login-right {
    padding: 50px;
}
}
@media screen and (max-width: 820px) {
.lyear-login-left {
    width: 100%;
    position: relative;
    z-index: 999;
    height: 300px;
}
.lyear-login-right {
    margin-left: 0;
}
}
@media screen and (max-width: 480px) {
.lyear-login-right {
    padding: 50px;
}
}
@media screen and (max-width: 320px) {
.lyear-login-right {
    padding: 30px;
}
}
</style>
</head>
  
<body>
<div class="lyear-login-box">
  <div class="lyear-login-left" style="background-image: url(/public/images/login-bg-4.jpg)">
    <div class="lyear-overlay"></div>
    <div class="lyear-featured">
      <h4>愿你有好运气，如果没有，愿你在不幸中学会慈悲；愿你被很多人爱，如果没有，愿你在寂寞中学会宽容。<small> - 刘瑜《愿你慢慢长大》</small></h4>
    </div>
  </div>
  <div class="lyear-login-right">
    
    <div class="lyear-logo text-center"> 
      <a href="#!"><img src="/public/images/logo-sidebar.png" alt="logo" /></a> 
    </div>
    <form action="/userRegister" method="post" id="registerForm">
      <div class="form-group">
        <label for="username">姓名</label>
        <input type="text" class="form-control" id="username" name="username" placeholder="请输入您的姓名">
      </div>
      <div class="form-group">
        <label for="username">账号</label>
        <input type="text" class="form-control" id="account" name="account" placeholder="请输入您的账号">
      </div>
      <div class="form-group">
        <label for="password">密码</label>
        <input type="password" class="form-control" id="password" name="password" placeholder="请输入您的密码">
      </div>
      <div class="form-group">
        <label for="password">确认密码</label>
        <input type="password" class="form-control" id="password2" name="password2" placeholder="请再次输入您的密码">
      </div>

      <div class="form-group">
        <label for="captcha">验证码</label>
        <div class="row">
          <div class="col-xs-7">
            <input type="text" name="captcha" id="captcha" class="form-control" placeholder="验证码">
          </div>
          <div class="col-xs-5">
            <img src="/getCode" class="pull-right" id="captcha" style="cursor: pointer;" onclick="this.src='/getCode?'" title="点击刷新" alt="captcha">
          </div>
        </div>
      </div>

      <div class="form-group">
        <button class="btn btn-block btn-warning" type="button" onclick="submitForm()">立即注册</button>
      </div>
      <footer class="text-center">
        <p class="m-b-0">Copyright © 2020 <a href="http://lyear.itshubao.com">IT书包</a>. All right reserved</p>
      </footer>
    </form>
    <input type="hidden" id="msg" value="{{msg}}"/>
    <input type="hidden" id="msgType" value="{{msgType}}"/>
  </div>
</div>
<script type="text/javascript" src="/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/public/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/public/js/lightyear.js"></script>
<script type="text/javascript" src="/public/js/main.min.js"></script>
<script type="text/javascript">
    $(function(){
        const msg = $("#msg").val();
        const msgType = $("#msgType").val();

        if(msg) {
          lightyear.notify(msg, msgType === 'error' ? 'danger' : 'info', 3500, msgType === 'error' ? 'mdi mdi-emoticon-dead' : 'mdi mdi-emoticon-happly', 'top', 'center');
        }

        if (window.localStorage) {
            $("#username").val(localStorage.getItem('username'));
            $("#account").val(localStorage.getItem('account'));
        }
    });

    function submitForm() {
        const body = {
            password: $("#password").val(),
            password2: $("#password2").val(),
            username: $("#username").val(),
            account: $("#account").val(),
            captcha: $("#captcha").val()
        }

        if(body.password != body.password2 ) {
            lightyear.notify('两次密码不一致2', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else if(!captcha) {
            lightyear.notify('验证码为空！', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else if(!body.account || !body.username || !body.password) {
            lightyear.notify('用户名、账号或密码为空！', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else if(body.account.length<4 || body.account.length>10) {
            lightyear.notify('账号长度应为4~10位！', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else if(body.username.length<2 || body.username.length>6) {
            lightyear.notify('姓名长度应为2~6位！', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else if(body.password.length<6 || body.account.length>15) {
            lightyear.notify('密码长度应为6~15位！', 'danger', 3500, 'mdi mdi-emoticon-dead', 'top', 'center');
        } else {
            if (window.localStorage) {
                localStorage.setItem('username', $("#username").val());
                localStorage.setItem('account', $("#account").val());
            }

            $("#registerForm").submit();
        }
        $("#msg, #msgType").val('');
    }
</script>
</body>
</html>